<div style="font-size:12px;">
This example accepting json data in the format of type:<br>
{ total: xxx, page: yyy, records: zzz, rows: [ <br>
{name1:”Row01″,name2:”Row 11″,name3:”Row 12″,name4:”Row 13″,name5:”Row 14″}, <br>
...<br>
Note the MySQL PHP code.
</div>
<br />
<table id="jsonmap" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pjmap" class="scroll" style="text-align:center;"></div>
<script src="jsonmap.js" type="text/javascript"> </script>
<br />
<div style="font-size:12px;">
<b> HTML </b>
<XMP>
...
<table id="jsonmap" class="scroll" cellpadding="0" cellspacing="0"></table>
<div id="pjmap" class="scroll" style="text-align:center;"></div>
<script src="jsonmap.js" type="text/javascript"> </script>
</XMP>    
<b>Java Scrpt code</b>
<XMP>
...
jQuery("#jsonmap").jqGrid({        
   	url:'server.php?q=4',
	datatype: "json",
   	colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
   	colModel:[
   		{name:'id',index:'id', width:55},
   		{name:'invdate',index:'invdate', width:90, jsonmap:"invdate"},
   		{name:'name',index:'name asc, invdate', width:100},
   		{name:'amount',index:'amount', width:80, align:"right"},
   		{name:'tax',index:'tax', width:80, align:"right"},		
   		{name:'total',index:'total', width:80,align:"right"},		
   		{name:'note',index:'note', width:150, sortable:false}		
   	],
   	rowNum:10,
   	rowList:[10,20,30],
   	imgpath: gridimgpath,
   	pager: jQuery('#pjmap'),
   	sortname: 'id',
    viewrecords: true,
    sortorder: "desc",
	jsonReader: {
		repeatitems : false,
		id: "0"
	},
	caption: "JSON Mapping",
	height: '100%'
}).navGrid('#pjmap',{edit:false,add:false,del:false});

</XMP>
<b>PHP with MySQL</b>
<XMP>
...
    $result = mysql_query("SELECT COUNT(*) AS count FROM invheader a, clients b WHERE a.client_id=b.client_id");
    $row = mysql_fetch_array($result,MYSQL_ASSOC);
    $count = $row['count'];
    if( $count >0 ) {
        $total_pages = ceil($count/$limit);
	} else {
		$total_pages = 0;
	}
    if ($page > $total_pages) $page=$total_pages;
	$start = $limit*$page - $limit; // do not put $limit*($page - 1)
    if ($start<0) $start = 0;
    $SQL = "SELECT a.id, a.invdate, b.name, a.amount,a.tax,a.total,a.note FROM invheader a, clients b WHERE a.client_id=b.client_id ORDER BY $sidx $sord LIMIT $start , $limit";
    $result = mysql_query( $SQL ) or die("Couldnt execute query.".mysql_error());
    $responce->page = $page;
    $responce->total = $total_pages;
    $responce->records = $count;
    $i=0;
    while($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
        $responce->rows[$i]=$row;
        $i++;
	} 
    echo $json->encode($responce); // coment if php 5     
    break;
...
</XMP>
</div>